package SmartQuestions;

import questionsObjects.*;

/**
 * Created with IntelliJ IDEA.
 * User: xpk
 * Date: 11/30/13
 * Time: 3:06 PM
 * To change this template use File | Settings | File Templates.
 */
class UserState {
    private QuestionHistory questionHistory;
    private int indexNewThemeOrNewComplexity = 0;

    public UserState() {
        this.questionHistory = new QuestionHistory();
    }

    public void pushAnswer(int index, boolean isRight) {
        questionHistory.pushValues(index, isRight);
    }

    public boolean isGrowDownOrUpComplexity(boolean type) {
        int counterOfAnswer = countOfAnswer(type);

        boolean isChange = counterOfAnswer > 2;
        indexNewThemeOrNewComplexity = isChange ? questionHistory.getSizeOfHistory() : indexNewThemeOrNewComplexity;

        return isChange;
    }

    public boolean haveDuplicatesInHistory(int index) {
        return questionHistory.haveDuplicatesInHistory(index);
    }

    public QuestionHistory getQuestionHistory() {
        return questionHistory;
    }

    private int countOfAnswer(boolean isRight) {
        int counterOfAnswer = questionHistory.countAnswers(indexNewThemeOrNewComplexity, isRight);
        return counterOfAnswer;
    }
}